home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
DBL Pascal Library
/
INIT Shell Folder
/
INIT Example ƒ
/
AddResPatch.p
next >
Wrap
Text File
|
1990-05-28
|
2KB
|
60 lines
unit INITShellResident;
{Copyright © 1990, David B. Lamkins}
{All rights reserved.}
{This unit must be compiled as a separate project, since code resource projects cannot have}
{multiple segments. We need this to be in a separate segment from the INIT loader since we}
{depend upon the presence of a the standard code header as a place to stash a handle to any}
{globals we may need for the patch. Also, it is much easier and safer to size and detach a}
{separate resource for the patch code than it is to play games with address arithmetic and}
{call _BlockMove to make a copy of the patch code. By convention this code resource will}
{have a type of 'IRES' (see INITShellLoader).}
interface
uses
INITShellGlobals, INITShellInlines, Retrace, SysEqu, ResCheck;
procedure main;
implementation
{$D-}
{$V-}
{$R-}
{This is the resident code. It may have local variables. Global data must be accessed through}
{the handle obtained from the GlobalsHandle function. See the INITShellInlines unit for further}
{programming details.}
procedure main;
{Patch for AddResource(h: Handle; rType: ResType; id: INTEGER; name: STR255);}
{The total size of all parameters on the stack is 14 bytes.}
{The offsets to be used for the arguments are, from right to left:}
{ name: 0, because it's the rightmost parameter}
{ id: 4, add the on-stack size of 'name' (=4) to reach 'id'}
{ rType: 6, add the on-stack size of 'id' (=2) to reach 'rType'}
{ h:10, add the on-stack size of 'rType' (=4) to reach 'h'}
type
IntPtr = ^INTEGER;
var
theHandleArg: Handle;
theTypeArg: OSType;
theIDArg: INTEGER;
theNameArg: StringPtr;
begin
Break; {debug stop, depending upon compile-time variable Debugging}
theHandleArg := Handle(LParam(10));
theTypeArg := OSType(LParam(6));
theIDArg := WParam(4);
theNameArg := Pointer(LParam(0));
if DangerousResource(theTypeArg, theIDArg, theNameArg, theHandleArg) then
begin
IntPtr(ResErr)^ := fLckdErr;
SysBeep(5);
DeallocateAndReturn(14);
end
else
SetTrapExit;
end;
end.